

import logging
import time


import op.op_dk  as op_dk

# 汇聚信息的节点
TARGET_NODE = 0x0004

# 任务 3 : 数据传到主星

class Task3_info:
    def __init__(self):
        self.list_watchSallite = []
        self.list_calculateSallite = []

task3_info = Task3_info()

def set(list_watchSallite, list_calculateSallite):
    task3_info.list_watchSallite = list_watchSallite
    task3_info.list_calculateSallite = list_calculateSallite

def run():
    logging.info(">>>>")
    logging.info("Scene-2 task3 Run...")
    logging.info("<<<<")

    work1_recv_imageData()
    work2_send_imageData_to_mainStar()

    while(end_check() == False):
        time.sleep(1)
        pass

    return True


# 启动主星的路由器程序，接收影像数据
def work1_recv_imageData():
    logging.info(">>>>")
    logging.info("work1 recv imageData...")
    # 启动主星的路由器程序，接收影像数据 

    op_dk.KubernetesCLI().exec_command_in_container(
        pod_name="mainStar", 
        container_name="mainStar", 
        command="python3 /app/mainStar.py", 
        namespace="default"
        )

    logging.info("<<<<")
    return

# 调用观测星的路由器程序，发送影像数据到计算星的主星
def work2_send_imageData_to_mainStar():
    logging.info(">>>>")
    logging.info("work1 send imageData to mainStar...")
    # 调用观测星的路由器程序，发送影像数据到计算星的主星

    op_dk.KubernetesCLI().exec_command_in_container(
        pod_name="watchStar", 
        container_name="watchStar", 
        command="python3 /app/watchStar.py", 
        namespace="default"
        )

    logging.info("<<<<")
    return True


#检测当前任务是否执行完成, 满足完成条件时，返回True
def end_check():
    logging.info(">>>>")
    logging.info("Scene-2 task3 end check...")
    logging.info("<<<<")
    return True